﻿Module mGroups

    Public Structure GroupCharDesc

        Dim name As String
        Dim conn As Connection

    End Structure

    Public Structure GroupDesc

        Dim ID As Long
        Dim Chars As List(Of GroupCharDesc)
        Dim count As Integer

    End Structure

    Private objGrpLock As New Object
    Private colGroups As New Collection

    Public Function GenerateGrpID()

        Dim id As Long

        For Each grp As GroupDesc In colGroups

            If grp.ID > id Then id = grp.ID

        Next


        Return (id + 1)

    End Function

    Public Sub FormGroup(ByRef conn As Connection, struct As GroupName)

        Dim conn2 As Connection = Socket.SockServer.ConnectionList.GetConnFromCharacterName(struct.Name)
        If conn2 Is Nothing Then Exit Sub

        SyncLock objGrpLock

            Dim desc As GroupDesc
            desc.ID = GenerateGrpID()
            desc.Chars = New List(Of GroupCharDesc)





            'code....






            colGroups.Add(desc, desc.ID.ToString)

        End SyncLock

    End Sub

    Public Sub AddToGrp(struct As GroupNameID, grpid As Long)

        'Dim pkt As Packet
        'pkt.PacketType = GamePacketType.AddToGrp
        'pkt.PacketOpCode = PacketOpCode.Notify

        'Dim added As Boolean

        'For i As Integer = 0 To 15

        '    Dim member As GroupNameID = CType(colGroups(grpid.ToString), GroupDesc).Chars(i)z

        '    If member.ID = 0 Then
        '        If Not added Then
        '            colGroups(grpid.ToString).chars(i) = struct
        '            added = True
        '        End If
        '    Else


        '        Dim conn As Connection = Socket.SockServer.ConnectionList.GetConnFromCharacterID(member.ID)

        '        pkt.Username = conn.Username
        '        Socket.SockServer.SendData(MakePacket(pkt, struct, conn.Crypto), conn)

        '    End If

        'Next



    End Sub

End Module
